<template>
  <div class="goods-user_left">
    <img class="user" :src="userQurl" /><span class="num">{{ usernaema }}</span>
  </div>
</template>

<script>
export default {
  name: "ToutiaoGoodsuser",
  props: ["id"],
  components: {},

  directives: {},

  data() {
    return {
      userid: this.id,
      userQurl: "",
      usernaema: "",
    };
  },

  mounted() {},
  created() {
    this.getUsername(this.userid);
  },
  methods: {
    // 获取发布人用户信息
    getUsername(userId) {
      let that = this;

      $.ajax({
        type: "get",
        url: `http://121.4.40.144/api/user/${userId}`,
        dataType: "json",
        contentType: "application/json",
        beforeSend: function (request) {
          request.setRequestHeader("token", localStorage.getItem("token"));
        },
        success: function (res) {
          //console.log(res);
          let qq = res.data.email.split("@")[0];
          that.userQurl = `https://thirdqq.qlogo.cn/g?b=qq&nk=${qq}&s=100`;
          that.usernaema = res.data.userName;
        },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.goods-user_left {
  width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 5px;
}
img.user {
  width: 25px;
  height: 25px;
  border-radius: 50px;
  vertical-align: -7px;
}
.goods-user_left span {
  padding-left: 5px;
}
</style>